package com.ebelter.bodyfatscale.ui.activity;

import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.ebelter.bodyfatscale.R;
import com.ebelter.btlibrary.util.ULog;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 设备绑定Activity，包含未绑定提示，设备搜索及绑定成功页
 * 只有未绑定时，才会进入这里
 */

public class BindDeviceHintActivity extends MonitorBluetoothStatusBaseActivity{

    private static final String TAG = "BindDeviceHintActivity";

    @Override
    protected int loadLayoutById() {
        return R.layout.activity_bind_hint;
    }



    @Override
    protected void initViews() {
    }

    @Override
    protected void initData() {

    }

    @BindView(R.id.btn_next_bind)
    TextView nextTv;

    @OnClick({R.id.iv_back_bind,R.id.btn_next_bind})
    public void btClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back_bind:
               finish();
                break;
            case R.id.btn_next_bind:
                Intent intent=new Intent(this,BindDeviceActivity.class);
                startActivity(intent);
                finish();
                break;

        }
    }

    @Override
    protected void bluetoothStationReceive(Intent intent,String action) {
        super.bluetoothStationReceive(intent,action);
        if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
            int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
            switch (state) {
                case BluetoothAdapter.STATE_OFF:
                    ULog.i(TAG, "STATE_OFF 手机蓝牙关闭");
                    nextTv.setEnabled(false);

                    break;
                case BluetoothAdapter.STATE_TURNING_OFF:
                    ULog.i(TAG, "STATE_TURNING_OFF 手机蓝牙正在关闭");
                    nextTv.setEnabled(false);
                    break;
                case BluetoothAdapter.STATE_ON:
                    ULog.i(TAG, "STATE_ON 手机蓝牙开启");
                    nextTv.setEnabled(true);
                    break;
                case BluetoothAdapter.STATE_TURNING_ON:
                    ULog.i(TAG, "STATE_TURNING_ON 手机蓝牙正在开启");
                    break;
            }
        }
    }



}
